﻿using System.Data;
using System.Data.SqlClient;
namespace MyWeb.Data
{
	public class tblSTAFFDAL : SqlDataProvider
	{

		#region[tblSTAFF_GetbyAll]
		public DataTable tblSTAFF_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tblSTAFF_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				return GetTable(cmd);
			}
		}
		#endregion
		#region[tblSTAFF_GetbyId]
		public DataTable tblSTAFF_GetById(string STAFF_ID)
		{
			using (var cmd = new SqlCommand("sp_tblSTAFF_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STAFF_ID", STAFF_ID));return GetTable(cmd);
			}
		}
		#endregion
		#region[tblSTAFF_GetbyTop]
		public DataTable tblSTAFF_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tblSTAFF_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				return GetTable(cmd);
			}
		}
		#endregion
		#region[tblSTAFF_GetbySTAFF_TYPE_CODE]
		public DataTable tblSTAFF_GetBySTAFF_TYPE_CODE(string STAFF_TYPE_CODE)
		{
			using (var cmd = new SqlCommand("sp_tblSTAFF_GetBySTAFF_TYPE_CODE", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STAFF_TYPE_CODE", STAFF_TYPE_CODE));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblSTAFF_Insert]
		public void tblSTAFF_Insert(tblSTAFFInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblSTAFF_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STAFF_CODE", Data.STAFF_CODE));
				cmd.Parameters.Add(new SqlParameter("@STAFF_FIRSTNAME", Data.STAFF_FIRSTNAME));
				cmd.Parameters.Add(new SqlParameter("@STAFF_LASTNAME", Data.STAFF_LASTNAME));
				cmd.Parameters.Add(new SqlParameter("@BIRTHDAY", Data.BIRTHDAY));
				cmd.Parameters.Add(new SqlParameter("@ADDRESS", Data.ADDRESS));
				cmd.Parameters.Add(new SqlParameter("@EMAIL", Data.EMAIL));
				cmd.Parameters.Add(new SqlParameter("@PHONE", Data.PHONE));
				cmd.Parameters.Add(new SqlParameter("@STAFF_TYPE_CODE", Data.STAFF_TYPE_CODE));
				cmd.Parameters.Add(new SqlParameter("@CREATOR", Data.CREATOR));
				cmd.Parameters.Add(new SqlParameter("@CREATED_DATE", Data.CREATED_DATE));
				cmd.Parameters.Add(new SqlParameter("@MODIFIER", Data.MODIFIER));
				cmd.Parameters.Add(new SqlParameter("@MODIFIED_DATE", Data.MODIFIED_DATE));
				ExeCuteNonquery(cmd);
			}
		}
		#endregion
		#region[tblSTAFF_Update]
		public void tblSTAFF_Update(tblSTAFFInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblSTAFF_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STAFF_ID", Data.STAFF_ID));
				cmd.Parameters.Add(new SqlParameter("@STAFF_CODE", Data.STAFF_CODE));
				cmd.Parameters.Add(new SqlParameter("@STAFF_FIRSTNAME", Data.STAFF_FIRSTNAME));
				cmd.Parameters.Add(new SqlParameter("@STAFF_LASTNAME", Data.STAFF_LASTNAME));
				cmd.Parameters.Add(new SqlParameter("@BIRTHDAY", Data.BIRTHDAY));
				cmd.Parameters.Add(new SqlParameter("@ADDRESS", Data.ADDRESS));
				cmd.Parameters.Add(new SqlParameter("@EMAIL", Data.EMAIL));
				cmd.Parameters.Add(new SqlParameter("@PHONE", Data.PHONE));
				cmd.Parameters.Add(new SqlParameter("@STAFF_TYPE_CODE", Data.STAFF_TYPE_CODE));
				cmd.Parameters.Add(new SqlParameter("@CREATOR", Data.CREATOR));
				cmd.Parameters.Add(new SqlParameter("@CREATED_DATE", Data.CREATED_DATE));
				cmd.Parameters.Add(new SqlParameter("@MODIFIER", Data.MODIFIER));
				cmd.Parameters.Add(new SqlParameter("@MODIFIED_DATE", Data.MODIFIED_DATE));
				ExeCuteNonquery(cmd);
			}
		}
		#endregion
		#region[tblSTAFF_Delete]
		public void tblSTAFF_Delete(string STAFF_ID)
		{
			using (var cmd = new SqlCommand("sp_tblSTAFF_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STAFF_ID",STAFF_ID));
				ExeCuteNonquery(cmd);
			}
		}
		#endregion

	}
}